﻿using System.IO;
using System.Collections;

namespace QAHelper.Common
{
    public class CSVReader
    {
        public CSVReader()
        {
        }

        /// <summary>
        /// Returns the file content with header as the first row of the list
        /// </summary>
        /// <param name="filename"></param>
        /// <returns>File content with header as the first row</returns>
        public ArrayList ReadFile(string filename)
        {
            ArrayList fileContent = new ArrayList();
            StreamReader reader = null;
            string temp = null;

            if (File.Exists(filename))
            {
                try
                {
                    reader = new StreamReader(filename);
                    temp = reader.ReadLine().Trim();

                    while (temp != null)
                    {                        
                        fileContent.Add(temp.Trim());
                        temp = reader.ReadLine();
                    }
                }
                finally
                {
                    if (reader != null)
                    {
                        reader.Dispose();
                        reader.Close();
                    }
                }
            }

            return fileContent;
        }
    }
}
